﻿@using WaiGaoQiaoWeb.Extensions
@{
    ViewBag.Title = "LoginfoIndex";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Head
{
    @Html.Css("form", "validationEngine")
    @Html.Js("form", "validate", "unobtrusive", "inlinevalidation")
    <script type="text/javascript" language="javascript">
        var maiheight = document.documentElement.clientHeight;
        var mainWidth = document.documentElement.clientWidth - 3; // 减去边框和左边的宽度
        var gh = maiheight - 213;
        $(document).ready(function () {
            var option = {
                height: maiheight - 80,
                width: $(document).width(),
                url: '@Url.Action("GetLogList")', // 参数要放在）括号的外面
                dataType: 'json',
                colModel: [
					{ display: '用户登录名称', name: 'LogName', width: 100, sortable: false, hide: false, align: 'left', iskey: true },
                    { display: '登录密码', name: 'LogPassword', width: 100, sortable: false, hide: false, align: 'left' },
					{ display: '密码提示', name: 'PasswordHint', width: 100, sortable: false, hide: false, align: 'left' },
					{ display: '登录时间', name: 'LogDt', width: 150, sortable: false, align: 'left' },
                    { display: '是否锁定', name: 'IsLocked', width: 150, sortable: false, align: 'left', process: formatType },
                    { display: '锁定时间', name: 'LockDt', width: 150, sortable: false, align: 'left' }
				],
                buttons: [
							{ name: 'Add', displayname: "新增用户", title: "新增用户", bclass: 'add', onpress: toolbarItemAdd_onclick },
                            { name: 'Delete', displayname: "删除用户信息", title: "删除用户信息", bclass: 'edit', onpress: toolbarItemDel_onclick },
							{ separator: true }
						 ],
                title: false,
                singleselected: false,
                usepager: true,
                resizable: true,
                page: 1, //默认当前页  
                total: 1, //总页面数  
                useRp: true, //是否可以动态设置每页显示的结果数  
                rp: 20, // 每页默认的结果数  
                rpOptions: [10, 15, 20], //可选择设定的每页结果数
                showcheckbox: true,
                selectedonclick: true,
                rowbinddata: true,
                hideOnSubmit: true, //隐藏提交  
                autoload: true
            };
            $("#LogUserList").flexigrid(option);
            function formatType(value) {
                if (value == "F") {
                    return "未锁定";
                }
                else if (value = "T") {
                    return "锁定";
                }
            }
            function toolbarItemAdd_onclick(cmd, grid) {
                OpenModelWindow('@Url.Action("Register")',
                                   { width: 450, height: 300, caption: "新增登录用户", onclose: refresh });
            }  // end of toolbarItemAdd_onclick
            function toolbarItemDel_onclick(cmd, grid) {
                var items = $("#LogUserList").getSelectedRows();
                if (items.length == 0) {
                    showLoadingMsg("请选择要绑定的菜单和登录用户!", { left: 400, top: 6 }, true, 3000);
                    return false;
                }
                if (!confirm("确定要删除登录用户吗？")) {
                    return false;
                }
                var rowcount = 0;
                for (var i = 0; i < items.length; i++) {
                    var logid = items[i][0];
                    $.ajax({
                        type: "POST",
                        url: '@Url.Action("DeleteLogUser")',
                        data: { logid: logid },
                        dataType: "json",
                        async: false,
                        success: function (data) {
                            if (data) {
                                rowcount = rowcount + ((data == -1) ? 0 : data);
                            }
                        },
                        error: function () { }
                    });   // end of ajax                    
                }
                refreshGrid();
                showLoadingMsg("共有" + rowcount.toString() + "个用户被删除!", { left: 400, top: 6 }, true, 3000);
            }  // end of toolbarItemUp_onclick
            function refreshGrid() {
                $("#LogUserList").flexReload();
            }
            function refresh() {
                showLoadingMsg("保存成功", { left: 200, top: 6 }, true, 3000);
                $("#LogUserList").flexReload();
            }
        });    //end document ready() 
    </script>
}
<table id="LogUserList" style="display: none;">
</table>
<input type="hidden" id="hdId" />
<input type="hidden" id="hdDisType" />
